import { eShiohoEvent, shiohoEventManager } from "../event/shiohoEventManager";
import { guideMgr } from "./guideMgr";
import { IGuideMediator } from "./iGuide";

export abstract class baseGuideMediator implements IGuideMediator {

    protected _mgr: guideMgr;
    protected _guideId: number;
    protected _stepId: number;

    constructor(mgr: guideMgr) {
        this._mgr = mgr;
    }

    protected abstract onRun(args?: any);
    protected abstract onUpdate(dt: number);
    protected abstract onComplete();

    run(guideId: number, stepId: number, args?: any) {
        this._guideId = guideId;
        this._stepId = stepId;
        this.onRun(args);
    }

    update(dt: number) {
        this.onUpdate(dt);
    }

    complete() {
        this.onComplete();
    }

    protected stepOver(guideId: number, stepId: number) {
        this._mgr.stepOver(guideId, stepId);
        shiohoEventManager.getInstance().dispatch(eShiohoEvent.StepOver, guideId, stepId);
    }
}


